package org.codeart.verifycode.controller;

import cn.hutool.core.map.MapUtil;
import org.codeart.common.util.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class NumberController {

    @GetMapping("/number-code/{size}")
    public R<Map<Object, Object>> numberCode(@PathVariable("size") Integer size) {
        double a = (Math.random() * 9 + 1) * Math.pow(10, size - 1);
        String b = (int) a + "";
        Map<Object, Object> data = MapUtil.builder().put("numberCode", b).build();
        return R.ok(data);
    }

}
